var SqlImport = {};
SqlImport.contextpath = "";
SqlImport.initPage = function(contextpath) {
	SqlImport.contextpath = contextpath;

	layui.use([ 'upload' ], function() {
		var upload = layui.upload, layer = layui.layer

		upload.render({
			elem : '#myfile',
			url : '/web2019/study/uploadStudyNotes.action',
			accept : 'file' //普通文件
			,
//			exts : '.MD' //允许上传的文件后缀
//			,
			done : function(res) {//返回值接收
				if (res.code == "0000") {
					layer.msg('导入成功！', {}, function() {
						location.reload();
					});
				} else {
					layer.msg('导入失败！', {}, function() {
						location.reload();
					});
				}
			}
		});

	});
}

SqlImport.ajaxSaveStory = function(data1) {
	$.ajax({
		type : "POST",
		url : "/web2019/user/ajaxSaveStory.action",
		dataType : "json",
		data : data1.field,
		beforeSend:function(){
			layer.load(1);
		},
		complete:function(){
			layer.close(layer.index-1);
		},
		success : function(data) {
			if (data.code == "0000") {
				layer.alert(data.message, {
					icon : 1,
					closeBtn : 0
				}, function(index) {
					layer.close(index);
					window.location.href = "/web2019/user/SqlImport.action";
				});
			} else {

			}
		},
		error : function(data) {

		}
	});
}
